<template>
  <div>
    <div
      class="wrapper-container"
      style="display: flex; flex-direction: column; width: 100%; margin: 0 50px"
    >
      <div class="search-container">
        <div class="search-container-left">
          <div
            class="search-container-item"
            v-for="(select, index) in selectList"
            :key="index"
          >
            <div v-if="select.type === 'select'" class="box">
              <span v-show="select.name">{{ select.name }}</span>

              <el-select
                v-model="select.val"
                style="width: 120px"
                size="mini"
                placeholder="请选择"
                @change="queryClassInfoDZ"
                clearable
              >
                <el-option
                  v-for="item in select.valList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </div>
            <div class="box" v-if="select.type === 'data'">
              <span class="demonstration" v-show="select.name">{{
                select.name
              }}</span>
              <el-date-picker
                v-model="select.val"
                type="date"
                placeholder="选择日期"
                prefix-icon="aaa"
              >
              </el-date-picker>
            </div>
            <div v-if="select.type === 'MultiSelect'" class="box"></div>
            <div v-if="select.type === 'btn'" class="box">
              <span class="demonstration" v-show="select.name">{{
                select.name
              }}</span>
              <el-input
                v-model="select.val"
                placeholder="请输入内容"
              ></el-input>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="export-right">
        <div  class="export-top" @click="exportData()">
          <img src="../../../../assets/assessment/icon-export.png" alt="" />
          <span>&ensp;导出Excel</span>
        </div>
      </div>

    <div class="body-manual-container">
      <div>
        <ul>
          <li>
            <span><div>节次</div></span>
            <span><div>星期一</div></span>
            <span><div>星期二</div></span>
            <span><div>星期三</div></span>
            <span><div>星期四</div></span>
            <span><div>星期五</div></span>
            <span><div>星期六</div></span>
            <span><div>星期日</div></span>
          </li>
          <li v-for="(item, index) in tableList" :key="index">
            <span
              ><div>
                <div>{{ item.jc }}</div>
                <br style="clear: both" /></div
            ></span>
            <span
              ><div>
                <div>{{ item.w1 }}</div>
                <br style="clear: both" /></div
            ></span>
            <span
              ><div>{{ item.w2 }}</div></span
            >
            <span
              ><div>{{ item.w3 }}</div></span
            >
            <span
              ><div>{{ item.w4 }}</div></span
            >
            <span
              ><div>{{ item.w5 }}</div></span
            >
            <span
              ><div>{{ item.w6 }}</div></span
            >
            <span
              ><div>{{ item.w7 }}</div></span
            >
          </li>
          <li>
            <span><div>备注</div></span>
            <span><div style="width: 1525px"></div></span>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import {kscx_kcb_dz, kscx_kcb_dy, kscx_kcb_exportDz, kscx_kcb_exportDy} from "@/api/trainingManagement/place.js";
import ButtonItem from "@/components/ButtonItem.vue";
export default {
  components: {
    ButtonItem,
  },
  data() {
    return {
      jsonFields: {
        节次: "jc",
        星期一: "w1",
        星期二: "w2",
        星期三: "w3",
        星期四: "w4",
        星期五: "w5",
        星期六: "w6",
        星期日: "w7",
      },
      role: "", //角色
      userInfo: {}, //用户信息
      tableList: [
        {
          sub: "1-2",
          Monday: "波斯语，180学时1，3，5，7，9，11，13，15周 赵小兰",
          Tuesday: "",
          Wednesday: "",
          Thursday: "",
          Friday: "",
          Saturday: "",
          Sunday: "",
        },
        {
          sub: "3-4",
          Monday: "",
          Tuesday: "",
          Wednesday: "波斯语基础试听，20学时，9-19周，张立新，L201",
          Thursday: "",
          Friday: "",
          Saturday: "",
          Sunday: "",
        },
        {
          sub: "5-6",
          Monday: "",
          Tuesday: "",
          Wednesday: "",
          Thursday: "马原,1周",
          Friday: "",
          Saturday: "",
          Sunday: "",
        },
        {
          sub: "7-8",
          Monday: "",
          Tuesday: "",
          Wednesday: "",
          Thursday: "",
          Friday: "",
          Saturday: "",
          Sunday: "",
        },
      ], //
      selectList: [
        {
          type: "select",
          name: "课表类型:",
          val: "专业班次课表",
          valList: [
            {
              value: "专业班次课表",
              label: "专业班次课表",
            },
            {
              value: "场地课表",
              label: "场地课表",
            },
          ],
        },
      ],
    };
  },
  created() {},
  mounted() {
    this.userInfo = JSON.parse(localStorage.getItem("xpaasui-userInfo"))
    this.role = this.userInfo.content.role_name;
    this.queryClassInfoDZ();
  },
  methods: {
    exportData() {
      var type = this.selectList[0].val;
      if (this.role == 'student') {
        kscx_kcb_exportDy(type).then((res) => {
          /** 获取生成设置好的文件名 */
          /** 接收文件流 */
          const blob = new Blob([res.data]);
          let url = URL.createObjectURL(blob);
          /** 模拟浏览器操作Document，并模拟下载动作 */
          let link = document.createElement("a");
          link.style.display = "none";
          link.href = url;
          link.setAttribute("download", "课表.xlsx");
          document.body.appendChild(link);
          link.click();
        });
      } else {
        kscx_kcb_exportDz(type).then((res) => {
          /** 获取生成设置好的文件名 */
          /** 接收文件流 */
          const blob = new Blob([res.data]);
          let url = URL.createObjectURL(blob);
          /** 模拟浏览器操作Document，并模拟下载动作 */
          let link = document.createElement("a");
          link.style.display = "none";
          link.href = url;
          link.setAttribute("download", "课表.xlsx");
          document.body.appendChild(link);
          link.click();
        });
      }
    },
    async queryClassInfoDZ(){
      var type = this.selectList[0].val;
      if (this.role == 'student') {
          // 学员
          const res = await kscx_kcb_dy(type);
          if (res.data.code == 200) {
            this.tableList = res.data.data;
          }
        } else {
          // 大队长
          const res = await kscx_kcb_dz(type);
          if (res.data.code == 200) {
            this.tableList = res.data.data;
          }
        }
    },
  },
  computed: {}, //计算属性
};
</script>
<style lang="less" scoped>
.assessment-container {
  .el-dialog__body {
    height: 251px;
  }
  .el-dialog__footer {
    padding: 10px 20px 45px;
  }
  .el-checkbox__inner:hover {
    border-color: #004ca7;
  }
  .el-checkbox__inner {
    border: 1px solid #004ca7;
    border-radius: 0;
    height: 18px;
    width: 18px;
  }
  .el-checkbox__inner::after {
    height: 10px;
    left: 6px;
  }
  .el-checkbox__input.is-checked .el-checkbox__inner,
  .el-checkbox__input.is-indeterminate .el-checkbox__inner {
    background-color: #004ca7;
    border-color: #004ca7;
  }
  .el-checkbox__input.is-checked + .el-checkbox__label {
    color: #004ca7;
  }
  .el-checkbox.is-bordered.is-checked {
    border-color: #004ca7;
  }
  .el-checkbox__input.is-focus .el-checkbox__inner {
    border-color: #004ca7;
  }
}
</style>
<style lang="less" scoped>
@import "../../../../styles/text.less";
.pagination-block {
  margin-top: 20px;
  display: flex;
  flex-direction: row;
  justify-content: center;
}
</style>
<style lang="less" scoped>
@import "../../../../styles/supervision.less";

.wrapper-container {
  width: 1711px;
  margin: 0 auto;
}

/deep/ .table-container {
  .el-table td,
  .el-table th.is-leaf,
  .el-table--border,
  .el-table--group {
    border-color: #c7d7eb;
  }

  .el-table__header tr,
  .el-table__header th {
    padding: 0;
    height: 76px;
    background-color: #edf2f9;
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    line-height: 20px;
    color: #004ca7;
  }

  .el-table__body tr,
  .el-table__body td {
    padding: 0;
    height: 86px;
  }

  .wrapper-button {
    display: flex;
    flex-direction: column;
    align-items: center;

    > div {
      margin-bottom: 8px;
    }
  }
  .table-data {
    width: 100%;
    border: 0.8px solid #004ca7;
    /*border-radius: 9px;*/
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #004ca7;
  }
}

.wrapper-container .search-container .search-container-left {
  width: 100%;
  flex-wrap: wrap;
  .search-container-item {
    width: 12%;
    margin-right: 0px;
    .box {
      > span {
        text-align: left;
      }
      display: flex;
      justify-content: space-evenly;
      margin-bottom: 20px;
      align-items: center;
    }
  }
}

/deep/.el-date-editor.el-input {
  width: 110px;
}
/deep/ .el-input--medium {
  width: 110px;
  .el-input__inner {
    height: 28px;
    width: 110px;
    padding: 0px 18px;
  }
}
/deep/ .el-table thead {
  color: #004ca7 !important;
}

.btn {
  margin-top: 271px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 271px;
  .submit {
    width: 84px;
    height: 27px;
    line-height: 8px;
  }
}
.bottom-block {
  // display: flex;
  flex-direction: row;
  justify-content: space-between !important;
  .export-button {
    width: 127px;
    height: 27px;
    background: #fff6ef;
    border: 1px solid #f3b815;
    border-radius: 4px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    margin-top: 14px;
    > img {
      width: 17px;
      height: 17px;
    }
    > span {
      margin-left: 12px;
      font-size: 14px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #f3b815;
    }
  }
  .text {
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    line-height: 39px;
    color: #004ca7;
  }
}

.search-button {
  width: 77px;
  height: 28px;
  line-height: 28px;
  background: #f1f8fe;
  border: 1px solid #51aef6;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  > span {
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #51aef6;
  }
  > img {
    width: 20px;
    height: 20px;
    margin-right: 4px;
  }
}

.body-manual-container {
  > div:nth-child(1) {
    width: calc(100% - 20px);
    // height: 785px;
    border: 1px solid rgba(0, 76, 167, 0.8);
    border-radius: 6px;
    margin: 30px auto 0;
    ul {
      list-style: none;
      li:nth-child(n) {
        border-bottom: 1px solid rgba(0, 76, 167, 0.4);
        height: auto;
        > span {
          box-sizing: border-box;
          display: inline-block;
          font-size: 14px;
          color: rgba(0, 76, 167, 1);
          // padding-left: 54px;
          border-right: 1px solid rgba(0, 76, 167, 0.4);
          height: 60px;
          // padding-top: 20px;
          vertical-align: middle;
          &:nth-child(n) {
            width: 12.5%;
            height: 100px;
          }
          &:last-child {
            border-right: none;
          }
          &.active {
            font-size: 16px;
            color: rgba(0, 76, 167, 1);
            font-weight: bold;
            background: rgba(77, 129, 192, 0.1);
            text-align: center;
            padding-left: 0;
          }
          > span {
            color: rgba(255, 56, 25, 1);
          }
          > div {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
          }
        }
      }
      li:nth-child(1) {
        > span {
          &:nth-child(n) {
            width: 12.5%;
            height: 60px;
            font-weight: bold;
          }
          > div {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 16px;
          }
        }
      }
    }
  }
}

.export-right {
  display: flex;
  align-items: center;
  justify-content: end;
  margin-right: 70px;
  margin-top: -50px;
}
.export-top {
  cursor: pointer;
  width: 127px;
  height: 27px;
  background: #fff6ef;
  border: 1px solid #f3b815;
  border-radius: 4px;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
  flex-direction: row;
  -webkit-box-align: center;
  align-items: center;
  -webkit-box-pack: center;
  justify-content: center;
  > img {
    width: 17px;
    height: 17px;
  }
  > span {
    color: #f3b815;
  }
}
</style>
